
#ifndef _THREADS_H_

#define _THREADS_H_

#include <windows.h>
#include "defs.h"

typedef struct _threadParams
{
	int i;
	int beta;
	int alpha;
	int depth;
	drawEntry* drawTable;
	move m;
} ThreadParams;

typedef struct _Queue
{
	ThreadParams **data;
	ThreadParams **front;
	ThreadParams **back;
	int capacity;
	int size;
	HANDLE queueReadSemaphore;
	HANDLE queueWriteSemaphore;
	HANDLE queueGuardMutex;
} Queue;

Queue operationQueue;
Queue resultQueue;

CRITICAL_SECTION TTLock;

void InitThreads(int threadCount, Queue *operationQueue, Queue *resultQueue);
void ReleaseThreads(int threadCount);
void InitQueue(Queue *queue,int capacity);
void FreeQueue(Queue *queue);

ThreadParams* RemoveFromQueue(Queue *queue);
void AddToQueue(Queue *queue, ThreadParams* threadParams);

DWORD WINAPI AlphaBetaThreadStarter(LPVOID params);

#endif